{template 'common/header'}
{template 'nav.inc'}
<style>
.alert {padding:6px}
</style>
<div class="container" style="margin-top:5px">
  <div class="row">
    <div class="col-xs-8">
        <ol class="breadcrumb alert alert-success">
            <li>首页</li>
            <li class="am-active">信息发布</li>
        </ol>
    </div>
    <div class="col-xs-4">
    <a href="{php echo $this->createMobileUrl('list')}" class="btn btn-primary"><span class="glyphicon glyphicon-share-alt"></span>&nbsp;返回首页</a>
    </div>
    </div>
    <div class="row">
    <div class="col-xs-12">
            <form action="" class="am-form" method="post" onsubmit="return checkform();">
                <input type="hidden" name="token" value="{$_W['token']}" />
                <input type="hidden" name="id"  value="{$good['id']}" />
                <fieldset>
                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>标题</span>
                        <input type="text" name="title" class="form-control" value="{$good['title']}"/>
                      </div>  
                    </div>
                    
                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>新旧</span>
                        <select name="rolex" class="form-control">
                            <option value='1' {if $good['rolex'] == 1}selected{/if}>9.9成新</option>
                            <option value='2' {if $good['rolex'] == 2}selected{/if}>9.5成新</option>
                            <option value='3' {if $good['rolex'] == 3}selected{/if}>9成新</option>
                            <option value='4' {if $good['rolex'] == 4}selected{/if}>8成新</option>
                            <option value='5' {if $good['rolex'] == 5}selected{/if}>7成新</option>
                            <option value='6' {if $good['rolex'] == 6}selected{/if}>6成新</option>
                       </select>
                      </div>  
                    </div>
                    
                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>分类</span>
                        <select name="pcate" class="form-control">
                        {loop $categorys $category}
                            <option value="{$category['id']}" {if $good['pcate'] == $category['id']}selected{/if} {if $category['parentid'] == 0}disabled='disabled'{/if}>
                            {if $category['parentid'] > 0}
                            &nbsp;&nbsp;&nbsp;&nbsp;|—
                            {/if}
                            {$category['name']}
                            </option>
                        {/loop}
                       </select>
                      </div>  
                    </div>

                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>转让价</span>
                        <input type="text" name="price" class="form-control" value="{$good['price']}"/>
                      </div>  
                    </div>
                    
                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>联系人</span>
                        <input type="text" name="realname" class="form-control" value="{$good['realname']}"/>
                      </div>  
                    </div>
                    
                    <div class="form-group">
                      <div class="input-group">
                        <span class="input-group-addon"><em>*</em>手机号</span>
                        <input type="text" name="mobile" class="form-control" value="{$good['mobile']}"/>
                      </div>  
                    </div>
                    
			        <div class="form-group">
			          <div class="input-group">
			            <span class=""><em>*</em>性别</span>
			          </div>  
			          <select name="sex" class="form-control">
			              <option value="0">男</option>
			              <option value="1">女</option>
			        </select>
			        </div>
                   <div class="form-group">
                      <div class="input-group">
                         <span class=""><em>*</em>商品描述(至少10个汉字)</span>
                      </div> 
                        <textarea class="form-control" rows="3" id="description" name="description">{$good['description']}</textarea>
                   </div>
                   
                   <div class="form-group">
                      <div class="input-group">
                         <span class=""><em>*</em>照片1</span>
                      </div> 
                      {php echo tpl_form_field_image('thumb1', $good['thumb1'], '', array('width' => 400, 'height' => 120, 'thumb'  => true));}
                   </div>
                 
                  <div class="form-group">
                      <div class="input-group">
                         <span class=""><em>*</em>照片2</span>
                      </div> 
                      {php echo tpl_form_field_image('thumb2', $good['thumb2']);}
                   </div>
                   
                   <div class="form-group">
                      <div class="input-group">
                         <span class=""><em>*</em>照片3</span>
                      </div> 
                      {php echo tpl_form_field_image('thumb3', $good['thumb3']);}
                   </div>
                   
                 <div class="am-form-group">
                     <input type="submit" id="submit" name="submit" class="btn btn-block btn-lg btn-primary" value="发布">
                 </div>
                </fieldset>
              </form>
    </div>
  </div>
</div>

<script type="text/javascript">
<!--
    function checkform() {
      if($("input[name='title']").val() == ''){
          $(".form-group").eq(0).addClass(' has-error');
          $("input[name='title']").attr("placeholder", "请输入标题");
          $("input[name='title']").focus();
          return false;
      }else{
    	  $(".form-group").eq(0).removeClass(' has-error');
          $(".form-group").eq(0).addClass(' has-success');
      }
      
      if($("input[name='price']").val() == ''){
          $(".form-group").eq(3).addClass(' has-error');
          $("input[name='price']").attr("placeholder", "请输入价格");
          $("input[name='price']").focus();
          return false;
      }else{
    	  $(".form-group").eq(3).removeClass(' has-error');
          $(".form-group").eq(3).addClass(' has-success');
      }
      
      if($("input[name='realname']").val() == ''){
          $(".form-group").eq(4).addClass(' has-error');
          $("input[name='realname']").attr("placeholder", "请输入联系人");
          $("input[name='realname']").focus();
          return false;
      }else{
    	  $(".form-group").eq(4).removeClass(' has-error');
          $(".form-group").eq(4).addClass(' has-success');
      }
      
      
      var mobile = $("input[name='mobile']").val();
      if(mobile == ''){
          $(".form-group").eq(5).addClass(' has-error');
          $("input[name='mobile']").attr("placeholder", "请输入手机号");
          $("input[name='mobile']").focus();
          return false;
      }else if(mobile.search(/^([0-9]{11})?$/) == -1) {
          $(".form-group").eq(5).addClass(' has-error');
          $("input[name='mobile']").attr("placeholder", "请输入正确的手机号码！");
          $("input[name='mobile']").focus();
          return false;
      }else{
    	  $(".form-group").eq(5).removeClass(' has-error');
          $(".form-group").eq(5).addClass(' has-success');
      }
      
      var assessment = $("#description").val();
      if (assessment.length < 5){
          $(".form-group").eq(7).addClass(' has-error');
          $("#description").attr("placeholder", "请输入商品描述");
          $("#description").focus();
          return false;
      }
      
      if($("input[name='thumb1']").val() == ''){
          $(".form-group").eq(8).addClass(' has-error');
          $("input[name='thumb1']").attr("placeholder", "请输上传照片");
          $("input[name='thumb1']").focus();
          return false;
      }else{
    	  $(".form-group").eq(8).removeClass(' has-error');
          $(".form-group").eq(8).addClass(' has-success');
      }
    }
</script>
{template 'common/footer'}